﻿using System;
using System.Linq;
using System.Collections.Generic;


namespace RMS.Utils.DatabaseSchema
{

    public class Table
    {
        #region [Properties]

        public string Name { get; set; }
        public List<Column> Columns { get; set; }

        #endregion
        public Table()
        {
            Columns = new List<Column>();
        }

        #region [Method]
        /// <summary>
        /// Get primary key columns from table
        /// </summary>
        /// <returns> List of columns</returns>
        public IEnumerable<Column> GetPks()
        {
            return this.Columns.Where<Column>((c) => c.IsPrimaryKey);
        }
        /// <summary>
        /// Get foreign key columns from table
        /// </summary>
        /// <returns> List of foreign key columns</returns>
        public IEnumerable<Column> GetFks()
        {
            return this.Columns.Where<Column>((c) => c.IsForeignKey);
        }
        #endregion
    }
}
